From: Marek Marczykowski Date: Mon, 27 Jun 2011 16:24:50 +0000 (+0100) Subject: libxl: Allocate memory for strings in libxl_device_disk X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10126 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=21e104aab3d138706d3a9e674ff6ad296419bf61;p=xen.git libxl: Allocate memory for strings in libxl_device_disk Memory for strings in libxl_device_disk must be allocated from outside of libxl__gc to not be freed at the end of function (by libxl__free_all). Fixes xl block-detach Signed-off-by: Marek Marczykowski Acked-by: Ian Campbell Signed-off-by: Ian Jackson Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 889d02cb7a..aad8e5a4a8 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -551,10 +551,12 @@ int libxl_devid_to_device_disk(libxl_ctx *ctx, uint32_t domid, goto out; disk->backend_domid = strtoul(val, NULL, 10); be_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend", diskpath)); - disk->pdev_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/params", be_path)); + disk->pdev_path = xs_read(ctx->xsh, XBT_NULL, + libxl__sprintf(&gc, "%s/params", be_path), NULL); val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/type", be_path)); libxl_string_to_backend(ctx, val, &(disk->backend)); - disk->vdev = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/dev", be_path)); + disk->vdev = xs_read(ctx->xsh, XBT_NULL, + libxl__sprintf(&gc, "%s/dev", be_path), NULL); val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/removable", be_path)); disk->removable = !strcmp(val, "1"); val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/mode", be_path));